<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 只打印最终的结果
    // var a = 0;
    // var sum = 0;
    // while (a <= 100) {
    //     sum = sum + a;
    //     a++;
    // }
    // console.log(sum);

    // 每一次的结果都会打印
    var a=0;
    var sum=0;
    while(a<=100){
        sum+=a;
        console.log(sum);
        a++;
    }

</script>

</html>